//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.come.Jpanel;

import com.tool.tcpimg.UIUtils;
import org.come.Frame.RankingListJframe;
import org.come.bean.LoginResult;
import org.come.until.AnalysisString;

import javax.swing.*;
import java.awt.*;
import java.awt.image.ImageObserver;
import java.math.BigDecimal;
import java.util.Map;

class MyRendererPHList extends JPanel implements ListCellRenderer {
    private int index;
    public static String vs;
    private Object value;
    private Map<String, Integer> map;
    private boolean isSelected;
    private static DefaultListModel<String> listModel;
    private ImageIcon mountBox;

    public MyRendererPHList() {
    }

    public MyRendererPHList(int index, Object value, boolean isSelected) {
        this.index = index;
        this.isSelected = isSelected;
        this.value = value;
    }

    public Dimension getPreferredSize() {
        return new Dimension(this.getWidth(), 28);
    }

    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        MyRendererPHList mr = new MyRendererPHList(index, value, isSelected);
        mr.removeAll();
        RankingListJpanel rankingListJpanel = RankingListJframe.getRankingListJframe().getRankingListJpanel();
        if (isSelected) {
            mr.setBackground(new Color(173, 173, 173, 150));
        } else if (RankingListJpanel.idx2 == index) {
            mr.setBackground(new Color(234, 217, 154, 150));
        } else {
            mr.setOpaque(false);
        }

        mr.setLayout(new FlowLayout(0));
        Box box = Box.createHorizontalBox();
        mr.add(box);
        return mr;
    }

    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D)g.create();
        LoginResult l = (LoginResult)this.value;
        g2d.setFont(UIUtils.TEXT_FONT1);
        if (this.index >= 9) {
            g2d.drawString(this.index + 1 + "", 44, 20);
        } else if (this.index > 4) {
            g2d.drawString(this.index + 1 + "", 49, 20);
        } else {
            if (this.mountBox == null) {
                this.mountBox = new ImageIcon("inkImg/background/ph/" + (10 + this.index + 1) + ".png");
            }

            if (this.index != 0 && this.index != 1 && this.index != 2) {
                g.drawImage(this.mountBox.getImage(), 45, 5, 18, 20, (ImageObserver)null);
            } else {
                g.drawImage(this.mountBox.getImage(), 45, 2, 21, 25, (ImageObserver)null);
            }
        }

        int selectedIndex = RankingListJframe.getRankingListJframe().getRankingListJpanel().getListPank().getSelectedIndex();
        FontMetrics fontMetrics;
        int w;
        String lvl;
        if (selectedIndex == 0) {
            g2d.setColor(UIUtils.COLOR_TEXT1);
            g2d.drawLine(8, 27, this.getWidth() - 20, 27);
            g2d.setColor(UIUtils.COLOR_CBG1);
            fontMetrics = g2d.getFontMetrics();
            w = fontMetrics.stringWidth(l.getRolename());
            g2d.drawString(l.getRolename(), 191 - w / 2, 20);
            lvl = AnalysisString.lvl(l.getGrade()) + "级";
            w = fontMetrics.stringWidth(lvl);
            g2d.drawString(lvl, 370 - w / 2, 20);
            if (l.getGold() == null) {
                l.setGold(BigDecimal.ZERO);
            }

            w = fontMetrics.stringWidth(l.getGold().toString());
            g2d.drawString(l.getGold().toString(), 512 - w / 2, 20);
        } else if (selectedIndex == 1) {
            g2d.setColor(UIUtils.COLOR_TEXT1);
            g2d.drawLine(8, 27, this.getWidth() - 20, 27);
            g2d.setColor(UIUtils.COLOR_CBG1);
            fontMetrics = g2d.getFontMetrics();
            w = fontMetrics.stringWidth(l.getRolename());
            g2d.drawString(l.getRolename(), 191 - w / 2, 20);
            lvl = AnalysisString.lvl(l.getGrade()) + "级";
            w = fontMetrics.stringWidth(lvl);
            g2d.drawString(lvl, 370 - w / 2, 20);
        } else if (selectedIndex == 2) {
            g2d.setColor(UIUtils.COLOR_TEXT1);
            g2d.drawLine(8, 27, this.getWidth() - 20, 27);
            g2d.setColor(UIUtils.COLOR_CBG1);
            fontMetrics = g2d.getFontMetrics();
            w = fontMetrics.stringWidth(l.getRolename());
            g2d.drawString(l.getRolename(), 191 - w / 2, 20);
            lvl = AnalysisString.lvl(l.getGrade()) + "级";
            w = fontMetrics.stringWidth(lvl);
            g2d.drawString(lvl, 370 - w / 2, 20);
        } else if (selectedIndex == 3) {
            g2d.setColor(UIUtils.COLOR_TEXT1);
            g2d.drawLine(8, 27, this.getWidth() - 20, 27);
            g2d.setColor(UIUtils.COLOR_CBG1);
            fontMetrics = g2d.getFontMetrics();
            w = fontMetrics.stringWidth(l.getRolename());
            g2d.drawString(l.getRolename(), 191 - w / 2, 20);
            lvl = AnalysisString.lvl(l.getGrade()) + "级";
            w = fontMetrics.stringWidth(lvl);
            g2d.drawString(lvl, 370 - w / 2, 20);
        } else if (selectedIndex == 4) {
            g2d.setColor(UIUtils.COLOR_TEXT1);
            g2d.drawLine(8, 27, this.getWidth() - 20, 27);
            g2d.setColor(UIUtils.COLOR_CBG1);
            fontMetrics = g2d.getFontMetrics();
            w = fontMetrics.stringWidth(l.getRolename());
            g2d.drawString(l.getRolename(), 191 - w / 2, 20);
            lvl = AnalysisString.lvl(l.getGrade()) + "级";
            w = fontMetrics.stringWidth(lvl);
            g2d.drawString(lvl, 370 - w / 2, 20);
        } else if (selectedIndex == 5) {
            g2d.setColor(UIUtils.COLOR_TEXT1);
            g2d.drawLine(8, 27, this.getWidth() - 20, 27);
            g2d.setColor(UIUtils.COLOR_CBG1);
            fontMetrics = g2d.getFontMetrics();
            w = fontMetrics.stringWidth(l.getRolename());
            g2d.drawString(l.getRolename(), 191 - w / 2, 20);
            lvl = AnalysisString.lvl(l.getGrade()) + "级";
            w = fontMetrics.stringWidth(lvl);
            g2d.drawString(lvl, 370 - w / 2, 20);
        } else if (selectedIndex == 6) {
            g2d.setColor(UIUtils.COLOR_TEXT1);
            g2d.drawLine(8, 27, this.getWidth() - 20, 27);
            g2d.setColor(UIUtils.COLOR_CBG1);
            fontMetrics = g2d.getFontMetrics();
            w = fontMetrics.stringWidth(l.getRolename());
            g2d.drawString(l.getRolename(), 191 - w / 2, 20);
            lvl = AnalysisString.lvl(l.getGrade()) + "级";
            w = fontMetrics.stringWidth(lvl);
            g2d.drawString(lvl, 370 - w / 2, 20);
            int intValue = l.getHjmax();
  //          boolean num = false;
            if (intValue != 0) {
                int v1 = intValue % 6 != 0 ? intValue / 6 + 1 : intValue / 6;
                int v2 = intValue % 6 == 0 ? 6 : intValue % 6;
                String v3 = v1 + "层" + v2 + "关";
                w = fontMetrics.stringWidth(v3);
                g2d.drawString(v3, 512 - w / 2, 20);
            }
        }

    }
}
